﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// 文件名：ClsStockOrderSchDAL.cs
/// 作  者：KIDY
/// 时  间：2007.01.04
/// 说  明：ClsStockOrderSchDAL类用于查询采购信息相关处理
/// </summary>
public class ClsStockOrderSchDAL
{
    /// <summary>
    /// 数据库连接字符串
    /// </summary>
    private static string strSqlConnectionString = ConfigurationManager.AppSettings["SQLCONNECTIONSTRING"];

    /// <summary>
    /// 获取所有的计量单位币别信息
    /// </summary>
    /// <param name="Co_ID">公司ID</param>
    /// <param name="User_ID">用户ID</param>
    /// <param name="Ds_ID">数据集ID</param>
    /// <returns>返回计量单位信息数据集</returns>
    public DataSet GetStockOrderSchDAL()
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GetStockOrderSch", con);

        dat.SelectCommand.CommandType = CommandType.StoredProcedure;

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }

   /// <summary>
   /// 获得已经确认的采购入库的采购单信息主表
   /// </summary>
   /// <param name="sType">采购入库类型</param>
   /// <returns></returns>
    public DataSet GetAuditedStockOrders(string sType)
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GetAuditedStoOrder", con);

        dat.SelectCommand.CommandType = CommandType.StoredProcedure;
        dat.SelectCommand.Parameters.Add("@type", sType);

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }

    /// <summary>
    /// 获得已经确认的采购入库确认单信息主表
    /// </summary>CREATE BY KIDY ON 20070105
    /// <param name="sType">采购入库类型</param>
    /// <returns></returns>
    public DataSet GetAuditedStoInValidateOrders(string sType)
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GetAuditedStoValidateOrder", con);

        dat.SelectCommand.CommandType = CommandType.StoredProcedure;
        dat.SelectCommand.Parameters.Add("@type", sType);

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }

    /// <summary>
    /// 获得已经确认的调拨出库单信息主表
    /// </summary>CREATE BY KIDY ON 20061230
    /// <param name="sType">类型</param>
    /// <returns></returns>
    public DataSet GetAuditedRemoveOrders(string sType)
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GetAuditedRemoveOutNo", con);

        dat.SelectCommand.CommandType = CommandType.StoredProcedure;
        dat.SelectCommand.Parameters.Add("@type", sType);

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
        return dst;
    }

    /// <summary>
    /// 获得已经确认的调拨出库确认单信息主表
    /// </summary>CREATE BY KIDY ON 20061231
    /// <param name="sType">类型</param>
    /// <returns></returns>
    public DataSet GetValiedRemoveOrders()
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GetValiedRemoveOutNo", con);
        dat.SelectCommand.CommandType = CommandType.StoredProcedure;

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }

    /// <summary>
    /// 获得已经确认的采购发票确认单信息主表
    /// </summary>CREATE BY KIDY ON 20070108
    /// <param name="sType">采购入库类型</param>
    /// <returns></returns>
    public DataSet GetAuditedStoInvoiceOrders(string sType)
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GetAuditedStoInvoiceOrder", con);

        dat.SelectCommand.CommandType = CommandType.StoredProcedure;
        dat.SelectCommand.Parameters.Add("@type", sType);

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }

    /// <summary>
    /// 获得已经确认的采购退货确认单信息主表
    /// </summary>CREATE BY KIDY ON 20070109
    /// <param name="sType">采购入库类型</param>
    /// <returns></returns>
    public DataSet GetAuditedStoBackValiOrder(string sType)
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GetAuditedStoBackValiOrder", con);

        dat.SelectCommand.CommandType = CommandType.StoredProcedure;
        dat.SelectCommand.Parameters.Add("@type", sType);

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }
}
